#include <iostream>
#include <cstring>
using namespace std;

int t;
int n,m,L,V,ans1,ans2;
int d[100005],v[100005],a[100005];
bool p[100005];
int check(){
    int res=0;
    for (int i=0;i<n;i++){
        for (int j=d[i];j<=L;j++){
            if (p[j]==true){
                if (v[i]>p[j]) res++;
                break;
            }
        }
    }
    return res;
}

int main (){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while (t--){
        cin >> n >> m >> L >> V;
        for (int i=0;i<n;i++){
            cin >> d[i] >> v[i] >> a[i];
        }
        for (int i=0;i<m;i++){
            int dis;
            cin >> dis;
            p[dis]=true;
        }
        for (int i=0;i<n;i++){
            for (int j=d[i];j<=L;j++){
                if (p[j]==true){
                    if (v[i]>V) ans1++;
                    break;
                }
            }
        }
        cout << ans1 << endl;
        for (int i=1;i<n;i++){
            for (int j=1;j<=L;j++){
                if (p[j]){
                    p[j]=false;
                    break;
                }
            }
            if (check()==ans1){
                ans2=i;
            }else{
                break;
            }
        }
        cout << ans2 << endl;
        ans1=ans2=0;
        memset(p,0,sizeof(p));
    }
    return 0;
}